package com.koron.ticket.work.workycinfo.service;

import com.koron.common.core.util.CodeTools;
import com.koron.ticket.work.workycinfo.bean.TicketYcInfoBean;
import com.koron.ticket.work.workycinfo.mapper.TicketYcInfoBeanMapper;
import org.koron.ebs.mybatis.SessionFactory;
import org.springframework.stereotype.Service;

@Service
public class WorkYcInfoService {

    public void insert(SessionFactory factory, TicketYcInfoBean ticketycinfobean) {
        TicketYcInfoBeanMapper ticketycinfobeanmapper = factory.getMapper(TicketYcInfoBeanMapper.class);
        ticketycinfobean.setId(CodeTools.getCode32());
        ticketycinfobeanmapper.insert(ticketycinfobean);
    }

    // 全量更新
    public void update(SessionFactory factory, TicketYcInfoBean ticketycinfobean) {
        TicketYcInfoBeanMapper ticketycinfobeanmapper = factory.getMapper(TicketYcInfoBeanMapper.class);
        ticketycinfobeanmapper.updateByPrimaryKey(ticketycinfobean);
        return;
    }

    // 可选更新
    public void updateSelective(SessionFactory factory, TicketYcInfoBean ticketycinfobean) {
        TicketYcInfoBeanMapper ticketycinfobeanmapper = factory.getMapper(TicketYcInfoBeanMapper.class);
        ticketycinfobeanmapper.updateByPrimaryKeySelective(ticketycinfobean);
        return;
    }

    public void save(SessionFactory factory, TicketYcInfoBean ticketycinfobean) {
        TicketYcInfoBeanMapper ticketycinfobeanmapper = factory.getMapper(TicketYcInfoBeanMapper.class);
        ticketycinfobeanmapper.deleteByWorkTicketId(ticketycinfobean.getWorkTicketId());
        ticketycinfobean.setId(CodeTools.getCode32());
        ticketycinfobeanmapper.insert(ticketycinfobean);
        return;
    }



//    public WorkInfo getSingle(SessionFactory factory, WorkInfoQuery workInfoQuery) {
//        TicketYcInfoBeanMapper ticketycinfobeanmapper = factory.getMapper(TicketYcInfoBeanMapper.class);
//        WorkInfo workInfo = ticketycinfobeanmapper.getSingle(workInfoQuery);
//        return workInfo;
//    }

    public TicketYcInfoBean getYcInfo(SessionFactory factory, String workTicketId) {
        TicketYcInfoBeanMapper ticketycinfobeanmapper = factory.getMapper(TicketYcInfoBeanMapper.class);
        TicketYcInfoBean bean = ticketycinfobeanmapper.queryByWorkTicketId(workTicketId);
        return bean;
    }

    public void deleteByWorkTicketId(SessionFactory factory, String workTicketId) {
        TicketYcInfoBeanMapper ticketycinfobeanmapper = factory.getMapper(TicketYcInfoBeanMapper.class);
        ticketycinfobeanmapper.deleteByWorkTicketId(workTicketId);
    }
}
